import Vue from 'vue'
import Router from 'vue-router'

// const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/login',
  //   name: 'login',
  //   hidden: true
  // },
  {
    path: '',
    component: Layout,
    redirect: '/dashboard/dashboard'
  },
  // { path: '/login', component: () => import('@/views/login'), name: '登录NxAdmin', hidden: true },
  {
    path: '/login',
    component: resolve => require(['../views/login/index.vue'], resolve),
    name: '登录NxAdmin',
    hidden: true
  },
  {
    path: '/404',
    component: resolve => require(['../views/errorPage/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: resolve => require(['../views/errorPage/401'], resolve),
    hidden: true
  },

  // 报表
  {
    path: '/dashboard',
    component: Layout,
    meta: { title: 'dashboard', icon: 'dashboard' },
    children: [
      {
        path: 'dashboard',
        name: 'dashboard',
        component: resolve => require(['../views/dashboard/dashboard'], resolve),
        meta: { title: 'dashboard', icon: 'dashboard' }
      }
    ]
  },
  // 商品列表
  {
    path: '/shoplist',
    component: Layout,
    redirect: '/shoplist/shoplist',
    meta: { title: 'shoplist', icon: 'tab' },
    children: [
      {
        path: 'shopList',
        name: 'shopList',
        component: resolve => require(['../views/shoplist/shoplist'], resolve),
        meta: { title: 'shoplist', icon: 'tab' }
      },
      {
        path: 'addInfo',
        name: 'shopList',
        hidden: true,
        component: () => import('@/views/shoplist/addInfo'),
        meta: { title: 'shoplist', icon: 'tab' }
      }
    ]
  },
  // 分类管理
  {
    path: '/classify',
    component: Layout,
    redirect: '/classify/classify',
    meta: { title: 'classify', icon: 'tab' },
    children: [
      {
        path: 'classify',
        name: 'classify',
        component: () => import('@/views/classify/classify'),
        meta: { title: 'classify', icon: 'tab' }
      }
    ]
  },
  // 订单管理
  {
    path: '/order',
    component: Layout,
    redirect: '/order/orderList',
    meta: { title: 'orderList', icon: 'tab' },
    children: [
      {
        path: 'order',
        name: 'order',
        component: () => import('@/views/order/orderList'),
        meta: { title: 'orderList', icon: 'tab' }
      }
    ]
  },
  // 客户管理
  {
    path: '/customer',
    component: Layout,
    redirect: '/customer/customer',
    meta: { title: 'customer', icon: 'tab' },
    children: [
      {
        path: 'customer',
        name: 'customer',
        component: () => import('@/views/customer/customer'),
        meta: { title: 'customer', icon: 'tab' }
      }
    ]
  },
  // 会员设置
  {
    path: '/member',
    component: Layout,
    redirect: '/member/member',
    meta: { title: 'member', icon: 'tab' },
    children: [
      {
        path: 'member',
        name: 'member',
        component: () => import('@/views/member/member'),
        meta: { title: 'member', icon: 'tab' }
      }
    ]
  },
  // 广告管理advertisement
  {
    path: '/advertisement',
    component: Layout,
    redirect: '/advertisement/advertisement',
    meta: { title: 'advertisement', icon: 'tab' },
    children: [
      {
        path: 'advertisement',
        name: 'advertisement',
        component: () => import('@/views/advertisement/advertisement'),
        meta: { title: 'advertisement', icon: 'tab' }
      }
    ]
  },
  // 账户管理account
  {
    path: '/account',
    component: Layout,
    redirect: '/account/account',
    meta: { title: 'account', icon: 'tab' },
    children: [
      {
        path: 'account',
        name: 'account',
        component: () => import('@/views/account/account'),
        meta: { title: 'account', icon: 'tab' }
      }
    ]
  }
  // 表单
  // {
  //   path: '/form',
  //   component: Layout,
  //   redirect: '/table/BaseForm',
  //   name: 'form',
  //   meta: {
  //     title: 'form',
  //     icon: 'form'
  //   },
  //   children: [
  //     {
  //       path: 'BaseForm',
  //       name: 'BaseForm',
  //       component: () => import('@/views/form/BaseForm'),
  //       meta: { title: 'BaseForm' }
  //     },
  //     {
  //       path: 'VueEditor',
  //       name: 'VueEditor',
  //       component: () => import('@/views/form/VueEditor'),
  //       meta: { title: 'VueEditor' }
  //     },
  //     {
  //       path: 'Upload',
  //       name: 'Upload',
  //       component: () => import('@/views/form/Upload'),
  //       meta: { title: 'Upload' }
  //     }
  //   ]
  // },
  // 表格
  // {
  //   path: '/table',
  //   component: Layout,
  //   redirect: '/table/complex-table',
  //   name: 'table',
  //   meta: {
  //     title: 'Table',
  //     icon: 'table'
  //   },
  //   children: [
  //     {
  //       path: 'complex-table',
  //       name: 'complex-table',
  //       component: () => import('@/views/table/complex-table'),
  //       meta: { title: 'complexTable' }
  //     },
  //     {
  //       path: 'TreeTable',
  //       name: 'TreeTable',
  //       component: () => import('@/views/table/tree-table/index'),
  //       meta: { title: 'treeTable' }
  //     }

  //   ]
  // }

]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
export const asyncRouterMap = [

  // {
  //   path: '/error',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   name: 'errorPages',
  //   meta: {
  //     title: 'errorPages',
  //     icon: '404'
  //   },
  //   children: [
  //     { path: '401', component: () => import('@/views/errorPage/401'), name: 'page401', meta: { title: 'page401', noCache: true }},
  //     { path: '404', component: () => import('@/views/errorPage/404'), name: 'page404', meta: { title: 'page404', noCache: true }}
  //   ]
  // },
  { path: '*', redirect: '/404', hidden: true }]
